package array

import (
	"log"

	"github.com/emirpasic/gods/lists/arraylist"
	"github.com/emirpasic/gods/utils"
)

// https://leetcode-cn.com/leetbook/read/top-interview-questions-easy/x2ba4i/
// 移动0 到数组最后
// 算法: 遍历
func MoveZeroes(nums []int) {
	notZeroIndex := 0
	for _, currentNum := range nums {
		if 0 != currentNum {
			nums[notZeroIndex] = currentNum
			notZeroIndex++
		}
	}
	for notZeroIndex < len(nums) {
		nums[notZeroIndex] = 0
		notZeroIndex++
	}

	// 以下代码仅测试用
	list := arraylist.New()
	list.Add(1, 2, 3)
	list.Sort(utils.IntComparator)
	log.Println(list.String())
}
